﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace QATestingLibrary
{
  public abstract class CustomUnitTesting
  {

    private TestContext testContextInstance;

    /// <summary>
    ///Gets or sets the test context which provides
    ///information about and functionality for the current test run.
    ///</summary>
    public TestContext TestContext
    {
      get
      {
        return testContextInstance;
      }
      set
      {
        testContextInstance = value;
      }
    }

    [TestCleanup()]
    public void TestCleanup()
    {
      FlushTest();
    }

    public void DebugDBContext()
    {
      if (TestContext != null)
      {
        foreach (System.Data.DataColumn column in TestContext.DataRow.Table.Columns)
        {
          TestContext.WriteLine("Dato prueba: {0} - valor: {1}", column.ColumnName, TestContext.DataRow[column.ColumnName]);
        }
      }
    }

    public void DebugContext()
    {
      if (TestContext != null)
      {
        foreach (KeyValuePair<string, object> values in TestContext.Properties)
        {
          TestContext.WriteLine(String.Format("Nombre: {0} - Valor: {1}", values.Key, values.Value));
        }
      }

    }

    public void FlushTest()
    {
      TestContext.WriteLine("{0} : {1}", TestContext.TestName, TestContext.CurrentTestOutcome);
      TestContext.WriteLine("");
    }

  }
}
